ENT.Type 	= "anim"
ENT.Base 	= "base_anim"

ENT.PrintName		= "SF Block"
ENT.Author		= "Nican"
ENT.Contact		= ""
ENT.Purpose		= "Block your enemies"
ENT.Instructions	= ""
ENT.Spawnable		= true
ENT.AdminSpawnable	= true

ENT.IsBlock = true
ENT.DEBUG = false

function ENT:SetupDataTables()
 
    self:DTVar( "Bool", 0, "AllowMotionVal" )
	self:DTVar( "Int", 0, "LifeVal" )
 
end

function ENT:AllowMotion()
	return  self.dt.AllowMotionVal
end

function ENT:SetAllowMotion( state )
	self.dt.AllowMotionVal = state
	
	if SERVER then
		local phys = self:GetPhysicsObject()
		if (phys:IsValid()) then
			phys:EnableMotion( state )
			
			if state == true then
				phys:Wake()
			end
		end
	end
end

function ENT:Life()
	return self.dt.LifeVal
end

function ENT:SetLife( life )
	if self.DEBUG then
		print("Updaing health: ", self, life )
	end
	self.dt.LifeVal = life
	
	if SERVER then
		self:UpdateSkin()
	end
end

function ENT:HealthFrac()
	return math.Clamp( self:Life() / Block.MaxHealth(), 0, 1 )
end

